package com.jisf.driver.auth;

import com.jisf.driver.response.Result;
import com.jisf.driver.response.ResultCode;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Classname MyAccessDeniedHandler
 * @Description TODO 权限不足异常
 * @Date 2022/4/4 22:43
 * @Created by jisf：【429627912@qq.com】
 */
@Component("myAccessDeniedHandler")
public class MyAccessDeniedHandler extends JsonAuthentication implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) throws IOException, ServletException {
        Result result = Result.error(ResultCode.NO_PERMISSION);
        this.WriteJSON(request, response, result);
    }
}
